package net.schmurgon.gwt.scaffold;

import com.google.gwt.app.place.Activity;
import com.google.gwt.app.place.ActivityMapper;
import com.google.gwt.app.place.Place;

/**
 * Instantiates activities for the mobile app.
 */
public final class ScaffoldMobileActivities implements ActivityMapper {
	private final ApplicationMasterActivities listActivityBuilder;
	private final ApplicationDetailsActivities detailsActivityBuilder;

	public ScaffoldMobileActivities(ApplicationMasterActivities listActivitiesBuilder, ApplicationDetailsActivities detailsActivityBuilder) {
		this.listActivityBuilder = listActivitiesBuilder;
		this.detailsActivityBuilder = detailsActivityBuilder;
	}

	public Activity getActivity(Place place) {
		Activity rtn = listActivityBuilder.getActivity(place);
		if (rtn == null) {
			rtn = detailsActivityBuilder.getActivity(place);
		}
		return rtn;
	}
}
